<template lang="">
    <div>
        <div class="table-body-box">
            <div class="study-center-form">
                <el-form style="margin-left:60px;margin-top:25px;" :inline="true">
                    <el-form-item label="讲师姓名：">
                        <el-input
                        clearable
                        size="small"
                        placeholder="请输入内容"
                        v-model="name">
                        </el-input>
                    </el-form-item>
                   
                    <el-form-item label="讲师类型">
                        <el-select size="small" v-model="teaType" placeholder="请选择活动区域">
                            <el-option label="全部" value=""></el-option>
                            <el-option label="内部讲师" value="0"></el-option>
                            <el-option label="外部讲师" value="1"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item style="margin-right:0;" label="部门">
                        <el-input
                        clearable
                        size="small"
                        placeholder="请输入内容"
                        v-model="deptName">
                        </el-input>
                    </el-form-item>
                    <el-form-item label="讲师风采">
                        <el-select size="small" v-model="teaIsGood" placeholder="请选择">
                            <el-option label="全部" :value="null"></el-option>
                            <el-option label="否" :value="0"></el-option>
                            <el-option label="是" :value="1"></el-option>
                        </el-select>
                    </el-form-item>
                </el-form>
                <div class="flex-row flex-btn-box">
                  <div style="width:50px;" class="btn-left">
                  </div>
                  <div class="btn-right">
                    <el-button type="primary" @click="addTeacher" size="small">新增</el-button>
                    <el-button type="primary" @click="deleteClass" :loading="searchLoading" size="small">删除</el-button>
                    <el-button type="primary" @click="searchList(1,10)" :loading="searchLoading" size="small">查询</el-button>
                  </div>
                </div>
            </div>
            <div class="study-center-table">
                <el-table 
                row-class-name="greyRow"
                height="70vh"
                :data="tableData" 
                style="width: 100%" 
                @selection-change="handleSelectionChange"
                :header-cell-style="{background:'#4787E3',color:'#ffffff'}">
                <el-table-column
                    type="selection"
                    width="55">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="username" align="center" label="讲师姓名">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="teaType" :formatter="initData" align="center" label="讲师类型">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="deptName" align="center" label="部门">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="honorTitle" align="center" label="荣誉称号">
                </el-table-column>
                <el-table-column show-overflow-tooltip prop="school" align="center" label="毕业院校">
                </el-table-column>
                <el-table-column
                align="center"
                fixed="right"
                label="操作" 
                width="150">
                <template slot-scope="scope">
                    <el-button style="text-decoration:underline;"  @click="teaEdit(scope.row.teaType,scope.row.userId,scope.row.id)" type="text" size="small">编辑</el-button>
                    <el-button style="text-decoration:underline;" @click="deleteOne(scope.row.id)" type="text" size="small">删除</el-button>
                </template>
                </el-table-column>
                </el-table>
                <div class="study-center-pagination flex-row">
                <pagination 
                @pageTurnNum="pageNum" 
                @pageTurnSize="pageSizeNum" 
                :total="total"></pagination>
                </div>
            </div>
        </div>
        <!-- 选择内外部导师弹窗 -->
        <el-dialog
          :close-on-click-modal='false'
          show-close
          title="新增导师类型"
          :visible.sync="checkChoose"
          width="500px"
          >
          <div style="margin:20px 0 0 20px;">
            <el-radio-group v-model="teacherRadio">
              <el-radio label="1">内部讲师</el-radio>
              <el-radio label="2">外部讲师</el-radio>
            </el-radio-group>
          </div>
            <span slot="footer" class="dialog-footer">
                <el-button size="small" @click="checkChoose = false">取 消</el-button>
                <el-button size="small" type="primary"  @click="goDetailModal">确 认</el-button>
            </span>
        </el-dialog>
        <!-- 新增内部导师弹窗 -->
        <el-dialog
            :close-on-click-modal='false'
            :title="tipText"
            :visible.sync="checkApply"
            width="800px"
            :before-close="handleClose0">
            <div class="class-detail-box">
                <div class="tips-box">
                    <div class="class-tips">{{tipTexts}}</div>
                </div>
                <div class="teacher">
                    <el-form
                        style="padding-left: 99px;"
                        label-width='120px'
                        ref="insertInTea" 
                        :model="inTeacherData" 
                        :rules="inTeacherRules" 
                    >
                        <el-form-item class="init-label is-required" style="margin-bottom:20px;" label="讲师姓名：">
                            <el-select
                                size="small"
                                v-model="teaName"
                                filterable
                                remote
                                placeholder="请输入关键词"
                                @change="handleSelect"
                                :remote-method="querySearch"
                                :loading="loading">
                                <el-option
                                    v-for="item in teaSelectList"
                                    :key="item.userId"
                                    :label="item.username"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                            <!-- <el-autocomplete
                            clearable
                            class="inline-input"
                            v-model="teaName"
                            size="small"
                            :fetch-suggestions="querySearch"
                            placeholder="请输入内容"
                            @select="handleSelect"
                            ></el-autocomplete> -->
                        </el-form-item>
                        <el-form-item style="margin-bottom:20px;" prop="honorTitle" label="荣誉称号：">
                            <el-input
                                clearable
                                size="small"
                                placeholder="请输入内容"
                                v-model="inTeacherData.honorTitle">
                            </el-input>
                        </el-form-item>
                        <el-form-item style="margin-bottom:10px;" label="讲师风采：" prop="isGood" v-if="editType == 1">
                            <el-switch
                            style="width:193px;" 
                            :active-value="1"
                            :inactive-value="0"
                            active-text="是"
                            inactive-text="否"
                            v-model="inTeacherData.isGood"></el-switch>
                        </el-form-item>
                        <div>
                            <el-form-item prop="achievement" style="margin-top:25px;" label="讲师成就：">
                                <el-input  style="height:100px !important;width:500px;" resize="none" type="textarea" v-model="inTeacherData.achievement"></el-input>
                            </el-form-item>
                        </div>
                    </el-form>
                </div>
            </div>
            <div style="text-align:center;padding:36px 0 26px 0;">
                <span slot="footer" class="dialog-footer">
                    <el-button size="small" @click="closeDiloag('checkApply','insertInTea')">取 消</el-button>
                    <el-button size="small" type="primary" @click="addInTea(editType)">确 定</el-button>
                </span>
            </div>    
        </el-dialog>
        <!-- 新增外部导师弹窗 -->
        <el-dialog
            :close-on-click-modal='false'
            :title="tipText"
            :visible.sync="checkApplys"
            width="800px"
            :before-close="handleClose1">
            <div class="class-detail-box">
                <div class="tips-box">
                    <div class="class-tips">{{tipTexts}}</div>
                </div>
                <div class="teacher">
                    <el-form
                        style="padding-left: 99px;"
                        label-width='120px'
                        ref="insertOutTea" 
                        :model="outTeacherData" 
                        :rules="outTeaRule" 
                    >
                        <el-form-item class="init-label is-required" prop="username" style="margin-bottom:20px;" label="讲师姓名：">
                            <el-input
                                clearable
                                size="small"
                                placeholder="请输入内容"
                                v-model="outTeacherData.username">
                            </el-input>
                        </el-form-item>
                        <el-form-item style="margin-bottom:20px;" prop="honorTitle" label="荣誉称号：">
                            <el-input
                                clearable
                                size="small"
                                placeholder="请输入内容"
                                v-model="outTeacherData.honorTitle">
                            </el-input>
                        </el-form-item>
                        <el-form-item style="margin-bottom:20px;" prop="jobTitle" label="职称：">
                            <el-input
                                clearable
                                size="small"
                                placeholder="请输入内容"
                                v-model="outTeacherData.jobTitle">
                            </el-input>
                        </el-form-item>
                        <el-form-item style="margin-bottom:20px;" prop="school" label="毕业院校：">
                        <el-input
                            clearable
                            size="small"
                            placeholder="请输入内容"
                            v-model="outTeacherData.school">
                            </el-input>
                        </el-form-item>
                        <el-form-item  prop='eduKind' style="margin-bottom:20px;" label="学历：">
                        <el-select size="small" 
                            filterable
                            remote
                            @change="eduKindSelect" 
                            v-model="eduKindName" 
                            placeholder="请选择">
                                <el-option
                                v-for="item in eduKindobj"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                                >
                                </el-option>
                            </el-select>
                        </el-form-item>
                        <div>
                            <el-form-item prop="achievement" style="margin-top:25px;" label="讲师成就：">
                                <el-input  style="height:100px !important;width:500px;" resize="none" type="textarea" v-model="outTeacherData.achievement"></el-input>
                            </el-form-item>
                        </div>
                    </el-form>
                </div>
            </div>
            <div style="text-align:center;padding:36px 0 26px 0;">
                <span slot="footer" class="dialog-footer">
                    <el-button size="small" @click="closeDiloag('checkApplys','insertOutTea')">取 消</el-button>
                    <el-button size="small" type="primary" @click="addOutTea(editType)">确 定</el-button>
                </span>
            </div>    
        </el-dialog>
    </div>
</template>
<script src="./studyjs/teacher"></script>
<style lang="less" scoped>
@import url("~@/pagecss/studyCenter");
@import url("~@/pagecss/classApply");
.init-label.is-required:not(.is-no-asterisk)
  > .el-form-item__label:before:before {
  content: "*";
  color: #f56c6c;
  margin-right: 4px;
}
.flex-btn-box {
  margin: 18px 0 10px 0;
  justify-content: space-between;
}
.class-tips {
  font-size: 16px;
}
</style>